/**************************************************START OF FILE*****************************************************/






/*------------------------------------------------------------------------------------------------------------------
Includes
*/
/*FreeRTOS*/
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
#include "semphr.h"

#include "lvgl_support.h"
#include "lvgl.h"


#include "xBSP_Gpio.h"

//GUI
#include "xGUI_MainTask.h"

/*------------------------------------------------------------------------------------------------------------------
Macros
*/


/*------------------------------------------------------------------------------------------------------------------
Variables
*/
bool s_lvgl_initialized = false;
lv_obj_t *pMainWidget = NULL;     //主体窗口


/*------------------------------------------------------------------------------------------------------------------
Functions
*/
static void lv_timer_user_callback(lv_timer_t * timer);


/*
********************************************************************************************************************
@ Brief  : 显示任务

@ Param  : None

@ Return : None

@ Author : LYC

@  Date  : 2020 - 04 - 03
********************************************************************************************************************
*/
void xGUI_MainTask(void *pvParameters)
{
	lv_port_pre_init();
    lv_init();
    lv_port_disp_init();   //显示初始化

	s_lvgl_initialized = true;

	pMainWidget = lv_scr_act();  //主体 Widget 创建

    lv_timer_create(lv_timer_user_callback,500,NULL);

    while(1)
    {	
        lv_task_handler();  //lvgl 任务处理函数
        vTaskDelay(5);
    }
}

static void lv_timer_user_callback(lv_timer_t * timer)
{
    static uint32_t colorCnt;
    lv_obj_set_style_bg_color(pMainWidget, lv_palette_main((lv_palette_t)colorCnt),LV_PART_MAIN);
    colorCnt++;
    colorCnt = colorCnt%12;
}

/****************************************************END OF FILE*****************************************************/

